package web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import beans.User;

import dao.RestaurantDAO;
import dao.UserDAO;

public class AdminRestaurantController extends MultiActionController {
 
	private RestaurantDAO restaurantDAO;

	private UserDAO userDAO;

	private LoggedUser loggedUser;

	public void setLoggedUser(LoggedUser loggedUser) {
		this.loggedUser = loggedUser;
	}
	
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	public void setRestaurantDAO(RestaurantDAO restaurantDAO) {
		this.restaurantDAO = restaurantDAO;
	}
	
	public ModelAndView restauracje(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
			User user = loggedUser.getLoggedUser();
			ModelMap modelMap = new ModelMap();
			modelMap.addAttribute("user", user);
			modelMap.addAttribute("adminRestaurantList", restaurantDAO.GetAllRestaurants());
			return new ModelAndView("restauracje", modelMap);
			
	}
}
